<template>
    <div class="header-container">
        <!-- 面包屑及菜单 -->
        <div class="breadCrumb">
            <el-button icon="el-icon-menu" size="mini" @click="menuCollapse"></el-button>
            <span class="text">首页</span>
        </div>
        <!-- 个人中心 -->
        <div class="user">
            <el-dropdown @command="handleCommand">
                <span class="el-dropdown-link">
                    <img class="user-logo" src="../assets/奥特曼.jpg" alt="用户头像">
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item command="cancel">退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>

<script>
/*
    * @desc 容器顶部组件
    * @author rz
    * @date 2024-2-20
*/
import Cookie from 'js-cookie'
export default {
    data() {
        return {

        }
    },
    methods: {
        // 改变菜单栏收缩
        menuCollapse() {
            this.$store.commit('menuCollapse');
        },
        // 退出
        handleCommand(command) {
            if (command === 'cancel') {
                // 移除token
                Cookie.remove('token');
                // 登出至登录页
                this.$router.push('/login');
                // 提示信息
                this.$message.success('成功退出');
            } else {
                this.$message.warning('其它模块暂未开放,请稍后');
            }
        }
    }
}
</script>

<style lang="less" scoped>
.header-container {
    width: calc(100% - 40px);
    height: 60px;
    padding: 0 20px;
    background-color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .text {
        color: white;
        font-size: 14px;
        margin-left: 10px;
    }

    .user-logo {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
}
</style>